package api

import (
	"pd/modules"
	"pd/modules/rdp_white_ip"

	"github.com/gin-gonic/gin"
)

// 通过写一个实体类，把内部的接口通过HTTP协议暴露出去
var handler = &Handler{}

// rdp_white_ip 的http实例，会实现gin的http Handler
type Handler struct {
	svc rdp_white_ip.Service
}

// Deprecated: Use GinConfig and init 
func NewRwiHttpHandler(svc rdp_white_ip.Service) *Handler {
	return &Handler{
		svc: svc,
	}
}

func (h *Handler) GinRegistry(r gin.IRouter) {
	r.POST("/rdp_white_ip/ip&username", h.createRdp_white_ip)
}

func (h *Handler) GinConfig() {
	h.svc = modules.GetImpl(rdp_white_ip.AppName).(rdp_white_ip.Service)
}

func (h *Handler) GinName() string {
	return rdp_white_ip.AppName
}

func init() {
	modules.RegistryGins(handler)
}
